
var SendLoginParam = {
	'dataType':'json',
	'beforeSubmit':beforeRequest,
	'success':nextResponse,
	'error':responseError,
};

ajaxForm_('#loginAdminForm', SendLoginParam);

function beforeRequest(formData, jqForm, options){
	toastr.options.positionClass = 'toast-top-full-width';
	var phoneReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
	if(!phoneReg.test(formData[0].value)){
		toastr.warning('账号格式不正确，要求为11位手机号');
		return false;
	}
	if(!formData[1].value || formData[1].value==''){
		toastr.warning('密码不能为空');
		return false;
	}
	if(formData[1].value.length < 6){
		toastr.warning('密码格式不正确，不少于6位');
		return false;
	}
}

function nextResponse(response) {
	if(response.success=='OK'){
		location.href=response.url;
	}
}

function responseError(XMLHttpRequest, textStatus, errorThrown) {
	if(XMLHttpRequest.status==422){
		var RegError = XMLHttpRequest.responseJSON.errors;
		for(var o in RegError){
			for (var i = 0; i < RegError[o].length; i++) {
				toastr.error(RegError[o][i]);
			}
		}
	}
}